/*
 * Copyright (c) ShaoxiongDu <Shaoxiong.dev@aliyun.com> 2021 all Rights Reserved
 */

package zh.codegym.task.task08.task0820;

import java.util.HashSet;
import java.util.Set;

/* 
动物集
*/

public class Solution {
    public static void main(String[] args) {
        Set<Cat> cats = createCats();
        Set<Dog> dogs = createDogs();

        Set<Object> pets = join(cats, dogs);
        printPets(pets);

        removeCats(pets, cats);
        printPets(pets);
    }

    public static Set<Cat> createCats() {
        HashSet<Cat> result = new HashSet<Cat>();
        result.add(new Cat());
        result.add(new Cat());
        result.add(new Cat());
        result.add(new Cat());

        return result;
    }

    public static Set<Dog> createDogs() {
        //在此编写你的代码
        HashSet<Dog> result = new HashSet<Dog>();
        result.add(new Dog());
        result.add(new Dog());
        result.add(new Dog());
        return result;
    }

    public static Set<Object> join(Set<Cat> cats, Set<Dog> dogs) {
        //在此编写你的代码
        HashSet<Object> objects = new HashSet<>();
        for (Cat cat : cats) {
            objects.add(cat);
        }
        for (Dog dog : dogs) {
            objects.add(dog);
        }
        return objects;
    }

    public static void removeCats(Set<Object> pets, Set<Cat> cats) {
        //在此编写你的代码
        pets.removeAll(cats);
    }

    public static void printPets(Set<Object> pets) {
        //在此编写你的代码
        for (Object pet : pets) {
            System.out.println(pet);
        }
    }

    //在此编写你的代码
    public static class Cat {

    }

    public static class Dog {

    }
}
